﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using SpringBeansEditor.Commands;
using System.Xml;

namespace SpringBeansEditor.GUIHelpers
{
    /// <summary>
    /// Interaction logic for GUICommand.xaml
    /// </summary>
    public partial class GUICommand : UserControl
    {
        
        IXmlCommand _command;
        public IXmlCommand Command
        {
            get
            {
                return _command;
            }

            set
            {
                _command = value;
                CommandBtn.Content = _command.GetLabel();
            }
        }

        XmlDocument _xml_data;
        XmlNode _curr_xml_node;

        public GUICommand()
        {
            InitializeComponent();
        }

        public GUICommand(IXmlCommand command)
        {
            InitializeComponent();
            Command = command;
        }

        public void SetCurrXMLNode(XmlDocument xml_data, XmlNode curr_xml_node)
        {
            _xml_data = xml_data;
            _curr_xml_node = curr_xml_node;
        }

        private void CommandBtn_Click(object sender, RoutedEventArgs e)
        {
            Command.Execute(_xml_data, _curr_xml_node);
        }

        public void Show()
        {
            Visibility = System.Windows.Visibility.Visible;
        }
        public void Hide()
        {
            Visibility = System.Windows.Visibility.Collapsed;
        }
    }
}
